package ui.custom.panel;

import java.text.ParseException;
import java.util.HashMap;
import java.util.List;

import javax.swing.JPanel;

import persistance.database.dao.LocationDAO;
import persistance.database.dao.ProjectPositionDAO;
import ui.custom.component.MyBar;
import domain.valueObejcts.Location;
import domain.valueObejcts.Floor;
import domain.valueObejcts.Project;

public class FloorPanel extends JPanel {

	private static final long serialVersionUID = 1L;
	
	private HashMap<String, String> filter = new HashMap<String, String>();
	
	public FloorPanel(NavigateFloors navigateFloors, PersonalPanel personalPanel, Floor floor, Project pro) throws ParseException {
		super();
		setLayout(null);
		filter.put("floor_id", floor.getId() + "");
		List<Location> bars = LocationDAO.read(filter);
		for (int i = 0; i < bars.size(); i++) {
			MyBar myBar = new MyBar(bars.get(i));
			myBar.setPersonalPanel(personalPanel);
			if(pro.getId() > 0){
				filter.put("floor_id", floor.getId() + "");
				filter.put("dateString", floor.getDate());
				filter.put("location_id", myBar.returnLocation().getId() + "");
				filter.put("project_id", pro.getId() + "");
				myBar.setPosition(ProjectPositionDAO.read(filter));
			}
			add(myBar);
		}
		
	}
}
